//
//  MVCView.m
//  PrintJob
//
//  Created by blank on 2017/5/8.
//  Copyright (c) 2017 CYN. All rights reserved.
//

#import "MVCView.h"
#import "Paper.h"

@interface MVCView ()

@property(nonatomic, strong) UIButton *buttonPrint;

@end

@implementation MVCView

- (instancetype)init {
    self = [super init];
    if (self) {
        [self setBackgroundColor:[UIColor lightGrayColor]];
        [self addSubview:self.buttonPrint];
    }

    return self;
}

- (UIButton *)buttonPrint {
    if (!_buttonPrint) {
        _buttonPrint = [UIButton buttonWithType:UIButtonTypeSystem];
        [_buttonPrint setFrame:CGRectMake(100, 100, 100, 50)];
        [_buttonPrint setTitle:@"Print" forState:UIControlStateNormal];
        [_buttonPrint addTarget:self
                         action:@selector(onPrintClick)
               forControlEvents:UIControlEventTouchUpInside];
    }
    return _buttonPrint;
}

- (void)onPrintClick {
    if ([_delegate respondsToSelector:@selector(onPrintBtnClick)]) {
        [_delegate onPrintBtnClick];
    }
}

- (void)printOnView:(Paper *)paper {
    NSLog(@"printing paper content %@", paper.content);
}

@end
